package mornd.test6;

import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

class Controller1 {

    public ModelAndView test1() {
        System.out.println("test1...");
        ModelAndView mav = new ModelAndView("view1");
        mav.addObject("name", "test1");
        return mav;
    }

    public String test2() {
        System.out.println("test2...");
        return "view2";
    }

    @ModelAttribute
    //@RequestMapping("/test3")
    public User test3() {
        System.out.println("test3...");
        return new User(1, "张三");
    }

    public User test4() {
        System.out.println("test4...");
        return new User(2, "李四");
    }

    public HttpEntity<User> test5() {
        System.out.println("test5...");
        return new HttpEntity<>(new User(3, "王五"));
    }

    public HttpHeaders test6() {
        System.out.println("test6...");
        HttpHeaders httpHeaders = new HttpHeaders();
        httpHeaders.add("content-Type", "text/html");
        return httpHeaders;
    }

    @ResponseBody
    public User test7() {
        System.out.println("test7...");
        return new User(4, "赵六");
    }
}
